$(function() {
	
	$(document).on("blur","#account",function(){
		account();
	});
	$(document).on("blur","#realName",function(){
		realName();
	});
	$(document).on("submit","#systemAccount_form",function(){
		if(account() && realName()){
			return true;
		}
		return false;
	});
});
function account(){
	var ok = false;
	var account = $("#account").val().trim();
	if(account == "") {
		$("#accounterr").html("请输入用户名");
		ok = false;
	} else{
		$("#accounterr").html("");
		$.ajax({
			type: "post", //请求的方式
			url: "/systemAccounts/account", //请求的路径
			dataType: "html", //返回的数据类型
			data: {account: account}, //要往后台提交的数据 request.getParameter("validate")
			async: false,
			success: function success(data) { //回调方法
				if($.trim(data)!=null && $.trim(data)!=""){
					ok = false;
					$("#accounterr").html("用户名已被占用,请更换");
				}else{
					ok = true;
				}
			}
		});
	}
	return ok;
}
function realName(){
	var ok = false;
	var realName = $("#realName").val().trim();
	if(realName == "") {
		$("#realNameerr").html("请输入真实姓名");
		ok = false;
	} else{
		$("#realNameerr").html("");
		ok = true;
	}
	return ok;
}
